package com.bnu.policy.Controller;

import com.bnu.policy.Entity.Result;
import com.bnu.policy.Service.PolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author ：Zzy1211
 * @date ：Created in 2019/11/6 21:19
 * @description：
 * @modified By：tyd
 * @version: $
 */
@RestController
@RequestMapping(value = "/policy")
public class PolicyController {

    @Resource
	private PolicyService policyService;

	/**
     * 功能：查询当前type下所有数据
     * 接口格式：http://localhost:8080/policy/findPolicy?pageNo=1&pageSize=12&p_type="教学资源"
     */
    @ResponseBody
    @PostMapping(value = "/findPolicy")
    public Object findPolicyByType(HttpServletRequest request){
        return policyService.findPolicy(request);
    }



	/**
     * 功能：高级搜索
     * 接口格式：http://localhost:8080/policy/findPolicy?pageNo=1&pageSize=12&p_type=&p_time=&content=
     */

    @ResponseBody
    @GetMapping(value = "/findPolicy")
    public Object findPolicyByWrapper(HttpServletRequest request){
       return policyService.findPolicyByWrapper(request);
    }


     /**
     * 功能：按照pid删除数据
     * 接口格式：http://localhost:8080/policy/deletePolicyByPid?&pid=
     */
   
    @RequestMapping(value="/deletePolicyByPid",method=RequestMethod.POST)
    @ResponseBody
    public Object deletePolicyByPid(HttpServletRequest request){
        return policyService.deletePolicyByPid(request);
    }


    /**
     * 功能：按照pid插入数据
     * 接口格式：http://localhost:8080/policy/insertPolicyByPid?&pid=&p_type=&content=&attachments=&p_time=&tag=
     */
   
    @RequestMapping(value="/insertPolicyByPid",method=RequestMethod.POST)
    @ResponseBody
    public Object insertPolicyByPid(HttpServletRequest request){
        return policyService.insertPolicyByPid(request);
    }


    /**
     * 功能：按照pid更新p_type,content,attachments,p_time,tag
     * 接口格式：http://localhost:8080/policy/updatePolicyAll?&pid=&p_type=&content=&attachments=&p_time&tag=
     */
   
    @RequestMapping(value="/updatePolicyAll",method=RequestMethod.POST)
    @ResponseBody
    public Object updatePolicyAll(HttpServletRequest request){
        return policyService.updatePolicyAll(request);
    }

    /**
     * 功能：按照pid更新审核状态
     * 接口格式：http://localhost:8080/policy/updatePolicyByPid?&pid=&tag=
     */
   
    @RequestMapping(value="/updatePolicyByPid",method=RequestMethod.POST)
    @ResponseBody
    public Object updatePolicyByPid(HttpServletRequest request){
        return policyService.updatePolicyByPid(request);
    }
}
